package com.csx.micrometer.invoke.config;

import com.csx.micrometer.invoke.core.inbound.webflux.MicrometerWebFluxHandlerInboundInterceptor;
import com.csx.micrometer.invoke.custom.TagsCustom;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.server.WebFilter;

import java.util.List;

/**
 * @author cuisongxu
 * @date 2023/2/9 9:42
 */
@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
public class WebFluxInboundMicrometerConfiguration {

    @ConditionalOnMissingBean
    @Bean
    public WebFilter micrometerHandlerInterceptor(List<TagsCustom> tagsCustom) {
        return new MicrometerWebFluxHandlerInboundInterceptor(tagsCustom);
    }
}
